package com.yhyvr.api.controller.store;/**
 * Created by zhangqin on 2017/5/26.
 */

import com.yhyvr.api.handle.ApiData;
import com.yhyvr.api.service.store.ApiBuyCardService;
import com.yhyvr.api.tool.ViewFactory;
import com.yhyvr.pojo.req.api.ApiReqBody;
import com.yhyvr.pojo.req.api.ApiReqData;
import com.yhyvr.pojo.req.api.store.buycard.ApiStoreBuyCardAddReq;
import com.yhyvr.pojo.req.api.store.buycard.ApiStoreBuyCardDeleteReq;
import com.yhyvr.pojo.req.api.store.buycard.ApiStoreBuyCardSaveReq;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 购物车
 *
 * @author
 * @create 2017-05-26 10:15
 **/
@Controller
public class ApiStoreBuyCardController {

    @Resource
    private ApiBuyCardService apiBuyCardService;
    @RequestMapping("/api/store/buy/card/list")
    public @ResponseBody
    ModelAndView cardList (@ApiData(h5Visit=true,h5VisitToken = false) ApiReqData<ApiReqBody> apiReqBodyApiReqData){
        return ViewFactory.buildApiJsonpView(apiBuyCardService.listCard(apiReqBodyApiReqData),apiReqBodyApiReqData.getCrossDomain());
    }

    @RequestMapping("/api/store/buy/card/save")
    public @ResponseBody
    ModelAndView cardsave (@ApiData(h5Visit=true,h5VisitToken = false) ApiReqData<ApiStoreBuyCardSaveReq> apiReqBodyApiReqData){
        return ViewFactory.buildApiJsonpView(apiBuyCardService.saveBuyCard(apiReqBodyApiReqData),apiReqBodyApiReqData.getCrossDomain());
    }

    @RequestMapping("/api/store/buy/card/add")
    public @ResponseBody
    ModelAndView cardadd (@ApiData(h5Visit=true,h5VisitToken = false) ApiReqData<ApiStoreBuyCardAddReq> apiReqBodyApiReqData){
        return ViewFactory.buildApiJsonpView(apiBuyCardService.addBuyCard(apiReqBodyApiReqData),apiReqBodyApiReqData.getCrossDomain());
    }

    @RequestMapping("/api/store/buy/card/delete")
    public @ResponseBody
    ModelAndView carddelete (@ApiData(h5Visit=true,h5VisitToken = false) ApiReqData<ApiStoreBuyCardDeleteReq> apiReqBodyApiReqData){
        return ViewFactory.buildApiJsonpView(apiBuyCardService.deleteBuyCard(apiReqBodyApiReqData),apiReqBodyApiReqData.getCrossDomain());
    }

    @RequestMapping("/api/store/common/info/bcnumber")
    public @ResponseBody
    ModelAndView cardNumber (@ApiData(h5Visit=true,h5VisitToken = false) ApiReqData<ApiReqBody> info){
        return ViewFactory.buildApiJsonpView(apiBuyCardService.commonInfo(info),info.getCrossDomain());
    }
}
